package com.mapbased.util;

import java.util.Map;
import com.mapbased.wfw.RenderContext;
import java.io.IOException;

public class ThreadStack
{
    public ThreadStack()
    {
        super();
    }
    public static void print(RenderContext rc)
        throws IOException
    {
        java.io.Writer w=rc.getOutputWriter();
        w.write("<pre>\n");
        print(w);
        w.write("</pre>\n");

    }
    public static void print(java.io.Writer w)
        throws IOException
    {
        Map  map= Thread.getAllStackTraces();
        for(java.util.Iterator i=map.entrySet().iterator();i.hasNext();)
        {
            Map.Entry e=(Map.Entry)i.next();
            Thread t=(Thread)e.getKey();
            w.write(t.toString()+ " "+t.getState()+"\n");

            StackTraceElement[] ste=(StackTraceElement[])e.getValue();

            for(int m=0;m <ste .length;m++)
            {
               w.write("\t");
               w.write(ste[m].toString());
               w.write("\n");
            }

        }
        w.flush();



    }

    public static void main(String[] args)
    {

    try
    {
        print(new java.io.PrintWriter(System.err));
    }
    catch(IOException ex)
    {
        ex.printStackTrace(
            );
    }
    }
}
